/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author K u Ku
 */
public class Validation {
    private Pattern pattern;
    private Matcher matcher;
    
    private static final String EMAIL_PATTERN = 
		"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
		+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    private static final String PHONE_NUMBER = "[0]{1}[1,9]{1}[0-9]{8,9}";
    
    public boolean overLength(String value, int lenght) {
        if (value.trim().length() >= lenght) {
            return false;
        } else {
            return true;
        }
    }
    
    public boolean isEmail(String email){
        pattern = Pattern.compile(EMAIL_PATTERN);
        matcher = pattern.matcher(email);
        return matcher.matches();
    }
    
    public boolean isPhoneNumber(String phoneNumber){
        pattern = Pattern.compile(PHONE_NUMBER);
        matcher = pattern.matcher(phoneNumber);
        return matcher.matches();
    }
}
